package com.yc.shopping.util;

import java.awt.Dimension;
import java.awt.Toolkit;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;

public class ShoppingUtil {
	
	
	//登录成功的管理员信息
	public static Map<String, Object> adminLogin = null;
	public static float totalPrice = 0;//当前结算金额
	public static float actualCollection= 0;//实收金额
	
	
	
	
	
	public static String objToString(Object obj) {
		if(null== obj) {
			return "";
		}
		return obj.toString();
	}
	/*
	 * 自动生成订单编号
	 */
	public static String genOrderId() {
		Date date =new Date();
		return "YC"+new SimpleDateFormat("yyyyMMddhhmmssSS").format(date);
	}
	
	/**
	 * 提示框
	 * @param shell
	 * @param title
	 * @param message
	 */
	public static void showMessage(Shell shell,String title,String message) {
		MessageBox mb =new MessageBox(shell, SWT.NONE);
		mb.setText(title);
		mb.setMessage(message);
		mb.open();
	}
	/**
	 * 窗口居中
	 */
	public static void centerWindows(Shell shell) {
		//获取屏幕的大小
		Dimension demo = Toolkit.getDefaultToolkit().getScreenSize();
		shell.setLocation((demo.width-shell.getSize().x)/2, (demo.height-shell.getSize().y)/2);
		
	}
	
	//获取登录用户名密码
	
	public static void userAndPwd() {
		
	}
	//字符串转日期
	public static java.sql.Date toDate(String birthday) throws ParseException {
		java.sql.Date date = java.sql.Date.valueOf(birthday);
		return date;
	}
}
